package com.itheima.service.impl;


import com.itheima.dao.AccountDao;
import com.itheima.service.AccountService;
import org.apache.ibatis.annotations.Param;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import javax.sql.DataSource;

public class AccountServiceImpl implements AccountService {

    private AccountDao accountDao;
    public void setAccountDao(AccountDao accountDao) {
        this.accountDao = accountDao;
    }

    /*private DataSource dataSource;

    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }*/

    public void transfer(String outName, String inName, Double money) {
      /*  DataSourceTransactionManager manager = new DataSourceTransactionManager(dataSource);
        TransactionStatus status = manager.getTransaction(null);*/
        accountDao.inMoney(outName,money);
//      int i = 1/0;
        accountDao.outMoney(inName,money);
        //提交事务
       /* manager.commit(status);*/
    }

}
